package io.github.tangwan.jdk8.thread;

import java.util.Random;
import java.util.concurrent.*;

/**
 * @author tangwan
 * @version V1.0
 * created on 2021/7/27 16:12
 * @since JDK 1.8
 */
public class MyThread5 {

    public static void main(String[] args) {
        ThreadFactory namedThreadFactory = Executors.defaultThreadFactory();
        ExecutorService executorService = new ThreadPoolExecutor(100, 100, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory);
        for (int i = 0;i < 100;i++){
            Callable<Integer> callable = () -> {
                System.out.println(Thread.currentThread().getName());
                return new Random().nextInt();
            };
            Future<Integer> future = executorService.submit(callable);
        }
        executorService.shutdown();
    }

}
